#ifndef MYLOGIN_H
#define MYLOGIN_H

#include <QDialog>
#include <QDebug>
#include <QUdpSocket>
#include <QTcpServer>
#include <QTcpSocket>
#include <QHostAddress>
#include <QByteArray>
#include <QList>
#include <QListWidget>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QFile>
#include <QFileInfo>
#include <QTimer>
#include "globalval.h"
#include <mqtthandler.h>
#define N 1024
//心跳包发送时间间隔
#define HEART_TIME 2000
//心跳包超时时间
#define TIME_OUT 4000

struct dev_addr{
   QString dev_name;
   QHostAddress dev_host;
   quint16 dev_port;
};

namespace Ui {
class MyLogin;
}

class MyLogin : public QDialog
{
    Q_OBJECT

public:
    explicit MyLogin(QWidget *parent = 0);
    ~MyLogin();

private:
    Ui::MyLogin *ui;
    QUdpSocket *udp_socket;
    QTcpSocket *tcp_socket;
    QTcpSocket *file_socket;
    QList<struct dev_addr> devList;
    //心跳包定时器
    QTimer *heart_pack_tm;
    QTimer *time_out_tm;
private slots:
    void searchButtonClickedSlot();
    void searchDeviceSlot();
    void listItemSlot(QListWidgetItem *);
    void linkButtonClickedSlot();
    void readyReadSlot();
    void connectedSlot();
    void disConnectedSlot();
    void  copyConnectedSlot();
    void  copyDisConnectedSlot();
    void heartPackSendSlot();
    void TimeOutSlot();
    void onIndexChanged(int index);
};

#endif // MYLOGIN_H
